package com.zhongjian.technologycal.mall.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.squareup.picasso.Picasso;
import com.zhongjian.technologycal.mall.R;
import com.zhongjian.technologycal.mall.base.BaseContacts;
import com.zhongjian.technologycal.mall.bean.CourseListBean;
import com.zhongjian.technologycal.mall.utils.PicassoRoundTransform;

import java.util.List;

/**
 * Created by wei on 2018/4/8.
 */

public class HotRecommendAdapter extends BaseQuickAdapter<CourseListBean,BaseViewHolder> {

    public HotRecommendAdapter(List data) {
        super(R.layout.items_business_college, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final CourseListBean item) {
        if (item == null){
            return;
        }
        helper.setText(R.id.college_tv_title,item.getCoursename());
        helper.setText(R.id.college_tv_content,item.getCoursebrief());
        helper.setText(R.id.college_tv_price,""+item.getCourseprice());
        if(item.isCanApply() == true){
            helper.setVisible(R.id.college_ll_buy,true);
            if(item.getCurstatus() == 0){
                helper.setText(R.id.college_tv_buy,"报名中");
                helper.setBackgroundRes(R.id.college_tv_buy,R.drawable.ripple_press2);
            }else if(item.getCurstatus() == 1){
                helper.setText(R.id.college_tv_buy,"授课中");
                helper.setBackgroundRes(R.id.college_tv_buy,R.drawable.ripple_pressa_order_list);
            }

        }else if(item.isCanApply() == false){
            helper.setVisible(R.id.college_ll_buy,false);
        }

        if(item.getCoursePhotos().size() > 0){

            Picasso.get().load(BaseContacts.BASE_URL + item.getCoursePhotos().get(0).getPhoto())
                    .transform(new PicassoRoundTransform())
                    .into((ImageView) helper.getView(R.id.college_iv_heading));
        }

    }


}
